//
//  MCWithdrowFooterView.m
//  TLYL
//
//  Created by MC on 2017/7/10.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCWithdrowFooterView.h"
@interface MCWithdrowFooterView ()

@property (nonatomic,strong)UIButton * btn_Withdrow;
@property (nonatomic,strong)UILabel  * lab_tip;

@end
@implementation MCWithdrowFooterView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}



-(void)createUI{
    
    self.backgroundColor=[UIColor whiteColor];
    //提款
    _btn_Withdrow=[[UIButton alloc]init];
    [_btn_Withdrow setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [_btn_Withdrow setTitle:@"提款" forState:UIControlStateNormal];
    _btn_Withdrow.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    _btn_Withdrow.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [_btn_Withdrow setBackgroundColor:RGB(80, 141, 207)];
    [self addSubview:_btn_Withdrow];
    [_btn_Withdrow addTarget:self action:@selector(action_Recharge) forControlEvents:UIControlEventTouchUpInside];
    _btn_Withdrow.layer.cornerRadius=5.0;
    _btn_Withdrow.clipsToBounds=YES;
    
    _lab_tip=[[UILabel alloc]init];
    _lab_tip.font=[UIFont systemFontOfSize:12];
    [self addSubview:_lab_tip];
    _lab_tip.numberOfLines=0;
    _lab_tip.textColor=RGB(100, 100, 100);
    _lab_tip.text=@"取款到账时间为1-5分钟，取款时间为：全天24小时";
    _lab_tip.textAlignment=NSTextAlignmentCenter;
    
    
    [self layOutConstraints];
    
}

/*
 * 点击提款
 */
-(void)action_Recharge{
    
    if ([self.delegate respondsToSelector:@selector(MCRechargeFooter_Withdrow)]) {
        [self.delegate MCRechargeFooter_Withdrow];
    }
    
}

-(void)layOutConstraints{
    
    [_btn_Withdrow mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(40);
        make.right.equalTo(self.mas_right).offset(-40);
        make.top.equalTo(self.mas_top).offset(50);
        make.height.mas_equalTo(50);
    }];
    
    
    
    [_lab_tip mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.right.equalTo(self.mas_right).offset(-10);
        make.bottom.equalTo(self.mas_bottom).offset(-10);
    }];
    
}

+(CGFloat)computeHeight:(id)info{
    NSString * content = @"取款到账时间为1-5分钟，取款时间为：全天24小时";
    CGSize textLabelSize    = [content boundingRectWithSize:CGSizeMake(G_SCREENWIDTH-20, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12]} context:nil].size;
    CGFloat min_H=50+50+textLabelSize.height+50;
    CGFloat H=G_SCREENHEIGHT-(64+50+100+10+80);
    if (H<min_H) {
        return min_H;
    }else{
        return H;
    }
    
}

/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */

@end
